﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;

namespace HcyWpfApp1
{
    public class TestPointUtils
    {
        public double Length { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }

        public Polygon[] GetPolygons(Point leftTopPoint) { 
            List<Polygon> polygons = new List<Polygon>();

            var polygon1 = new Polygon();
            polygon1.Stroke = new SolidColorBrush(Colors.Black); // 设置边框颜色                                                          // polygon.Fill = new SolidColorBrush(Colors.Blue);    // 设置填充颜色
            polygon1.StrokeThickness = 2;
            polygon1.Points = new PointCollection()
            {
               leftTopPoint,

               new Point(leftTopPoint.X+Length, leftTopPoint.Y),

               new Point(leftTopPoint.X+Length,Height+leftTopPoint.Y),

               new Point(leftTopPoint.X, leftTopPoint.Y+Height)
            };  
            var polygon2 = TestPointUtils.GetPolygon(TestPointUtils.GetPoints2(TestPointUtils.GetPoints()));

            polygons.Add(polygon1);
            //polygons.Add(polygon2);
            return polygons.ToArray();
        }

        public static PointCollection GetPoints() {
            var points = new PointCollection()
            {
                new Point(50,50),
                new Point(200,50),
                new Point(200,150),
                new Point(50,150),
            };

            return points;
        }
        public static PointCollection GetPoints2(PointCollection points) {
            PointCollection pointsNew = new PointCollection();
            for (int i = 0; i < points.Count; i++)
            {
                pointsNew.Add(new Point(points[i].X + 20, points[i].Y - 20));
            }
            return pointsNew;        
        }


        public static Line GetLine1() {
            // 绘制水平实线
            Line horizontalLine = new Line();
            horizontalLine.X1 = 50;
            horizontalLine.Y1 = 50;
            horizontalLine.X2 = 70;
            horizontalLine.Y2 = 30;
            horizontalLine.Stroke = Brushes.Black;
            horizontalLine.StrokeThickness = 2;
            return horizontalLine;
        }

        public static Line GetLine2()
        {
            // 绘制水平实线
            Line horizontalLine = new Line();
            horizontalLine.X1 = 200;
            horizontalLine.Y1 = 50;
            horizontalLine.X2 = 220;
            horizontalLine.Y2 = 30;
            horizontalLine.Stroke = Brushes.Black;
            horizontalLine.StrokeThickness = 2;
            return horizontalLine;
        }

        public static Line GetLine3()
        {
            // 绘制水平实线
            Line horizontalLine = new Line();
            horizontalLine.X1 = 200;
            horizontalLine.Y1 = 150;
            horizontalLine.X2 = 220;
            horizontalLine.Y2 = 130;
            horizontalLine.Stroke = Brushes.Black;
            horizontalLine.StrokeThickness = 2;
            return horizontalLine;
        }

        public static Line GetLine4()
        {
            // 绘制水平实线
            Line horizontalLine = new Line();
            horizontalLine.X1 = 50;
            horizontalLine.Y1 = 150;
            horizontalLine.X2 = 70;
            horizontalLine.Y2 = 130;
            horizontalLine.Stroke = Brushes.Red;
            horizontalLine.StrokeThickness = 2;
            horizontalLine.StrokeDashArray = new DoubleCollection { 2, 2 };
            return horizontalLine;
        }



        public static Polygon GetPolygon(PointCollection points)
        {     // 创建一个新的 Polygon 对象
            Polygon polygon = new Polygon();
            polygon.Stroke = new SolidColorBrush(Colors.Black); // 设置边框颜色
           // polygon.Fill = new SolidColorBrush(Colors.Blue);    // 设置填充颜色
            polygon.StrokeThickness = 2;
            polygon.Points = points;
            return polygon;
        }

    }
}
